﻿using AutoMapper;
using ScaffoldDemo.Entities;
using ScaffoldDemo.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ScaffoldDemo.AutoMapper.Profiles
{
    public class UserMapperProfile : Profile
    {
        public UserMapperProfile() 
        {
            // SysUser -> SysUserModel
            CreateMap<SysUser, SysUserModel>()
                .ForMember(dest => dest.UserId, opt => opt.MapFrom(src => src.Id))
                .ForMember(dest => dest.UserName, opt => opt.MapFrom(src => src.Name));

            // SysUserModel -> SysUser
            CreateMap<SysUserModel, SysUser>()
                .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.UserId))
                .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.UserName));
        }
    }
}